<?php
@require_once("config.php");
$user_id=$_GET["user_id"];
$user_name=$_GET["user_name"];
$goods_id=$_GET["goods_id"];
$goods_name=$_GET["goods_name"];
$goods_num=$_GET["goods_num"];
$goods_price=$_GET["goods_price"];
$goods_pic=$_GET["goods_pic"];
$sql="select * from shoppingcar where user_id='$user_id' and goods_id='$goods_id'";
$result=mysql_query($sql);
if(mysql_fetch_assoc($result)>0){
    $sql1="update shoppingcar set goods_num=goods_num+$goods_num where user_id='$user_id' and goods_id='$goods_id'";
}
else{
    $sql1="insert into shoppingcar(user_id,user_name,goods_id,goods_name,goods_num,goods_price,goods_pic) value('$user_id','$user_name','$goods_id','$goods_name','$goods_num','$goods_price','$goods_pic')";
}
mysql_query($sql1);
$arr=array();
if(mysql_affected_rows()>0){
$arr["status"]=true;
$arr["msg"]="加入购物车成功";
}else{
$arr["status"]=false;
$arr["msg"]="加入购物车失败";
}
echo json_encode($arr);
?>